package com.jingbian.cppccbackend.controller.user;


import com.github.pagehelper.PageInfo;
import com.jingbian.cppccbackend.entity.ActivityOutcomes;
import com.jingbian.cppccbackend.entity.Result;
import com.jingbian.cppccbackend.entity.dto.ActivitysOutcomesListDTO;
import com.jingbian.cppccbackend.service.user.IActivityOutcomesService;
import com.jingbian.cppccbackend.utils.ResultUtil;
import com.jingbian.cppccbackend.vo.ActivitiesOutcomesDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 活动成果表 前端控制器
 * </p>
 *
 * @author pum
 * @since 2025-03-01
 */
@RestController
@RequestMapping("/users/activityOutcomes")
public class ActivityOutcomesController {

  @Autowired
  private IActivityOutcomesService activityOutcomesService;

  /**
   * 发布活动成果
   */
  @PostMapping("/publish")
  public Result<String> publishActivityOutcomes(@RequestBody ActivityOutcomes activityOutcomes) {
      activityOutcomesService.publishOutcomes(activityOutcomes);
      return ResultUtil.success("活动成果发布成功！");
  }

  /**
   * 查询已发布的活动成果
   * @param activitysOutcomesListDTO
   */
  @PostMapping("/getList")
  public Result<PageInfo<ActivityOutcomes>> getOutcomesList(@RequestBody ActivitysOutcomesListDTO activitysOutcomesListDTO) {
    return ResultUtil.success(activityOutcomesService.geOutcomestList(activitysOutcomesListDTO));
  }

  /**
   * 获取某一活动的活动详情
   */
  @GetMapping("/detail/{oid}")
  public Result<ActivitiesOutcomesDetailVO> outcomesDetail(@PathVariable Integer oid) {
     return ResultUtil.success(activityOutcomesService.getOutcomesDetail(oid));
  }
}
